package nuist.hanniko.stu.webbackend.dao.mapper;

import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public interface UserRoleMapper {
    @Insert("insert into user_role(uid,role) value (#{uid},#{role})")
    int add(@Param("uid") String uid, @Param("role") String role);

    @Delete("delete from user_role where uid=#{uid} and role=#{role}")
    int delete(@Param("uid") String uid, @Param("role") String role);

    @Select("select role from user_role where uid=#{uid}")
    List<String> getAllRolesById(@Param("uid") String uid);

    @Select("select role from user_role where uid=#{uid} and role=#{role}")
    String getRoleByIdAndRole(@Param("uid") String uid,
                              @Param("role") String role);
}
